<template>
  <div class="my-tag">
              <input
              v-if="isShow"
              v-focus
                class="input"
                type="text"
                placeholder="输入标签"
                v-model.trim="taskName"
                @keydown.enter="inputTag"
                @blur="isShow =false"
              />
              <div class="text" 
              @dblclick="back"
              v-else>{{value}}</div>
            </div>
</template>

<script>
export default {
  props: {
    value: {
      type:String,
      required:true
    }
  },

  data() {
    return {
      isShow:false,
      taskName:''
    };
  },

  methods: {
    inputTag() {
      this.$emit('input',this.taskName)
      this.isShow=false
    },
    back() {
      this.isShow=true,
    this.taskName =this.value

    }
  },
};
</script>

<style lang="less" scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>